This notebook can be used to generate tradeoff values from all the Pareto-optimal data point files hard-coded in the dictionary pfs. Currently this notebook processes these Pareto-optimal fronts.
%reload_ext autoreload
%autoreload 2
import sys
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from mpl_toolkits.mplot3d import Axes3D
plt.rcParams.update({'figure.max_open_warning': 0})
In this case we are computing the depth-contours from the convex-hulls. So we are using the tda.simple_shape module.
sys.path.append('../')
from vis.tda import simple_shape as ss
from vis.utils import io
pfs = {'dtlz2': ['3d', '4d', '8d'], \
'dtlz2-nbi': ['3d', '4d', '8d'], \
'debmdk': ['3d', '4d', '8d'], \
'debmdk-nbi': ['3d', '4d', '8d'], \
'debmdk-all': ['3d', '4d', '8d'], \
'debmdk-all-nbi': ['3d', '4d', '8d'], \
'dtlz8': ['3d', '4d', '6d', '8d'], \
'dtlz8-nbi': ['3d', '4d', '6d', '8d'], \
'c2dtlz2': ['3d', '4d', '5d', '8d'], \
'c2dtlz2-nbi': ['3d', '4d', '5d', '8d'], \
'cdebmdk': ['3d', '4d', '8d'], \
'cdebmdk-nbi': ['3d', '4d', '8d'], \
'c0dtlz2': ['3d', '4d', '8d'], \
'c0dtlz2-nbi': ['3d', '4d', '8d'], \
'crash-nbi': ['3d'], 'crash-c1-nbi': ['3d'], 'crash-c2-nbi': ['3d'], \
'gaa': ['10d'], \
'gaa-nbi': ['10d']}
for pf in list(pfs.keys())[0:-2]:
for dim in pfs[pf]:
fullpathf = "../data/{0:s}/{1:s}/dataf.csv".format(pf, dim)
if os.path.exists(fullpathf):
path, filenamef = os.path.split(fullpathf)
dirs = path.split('/')
frontname = dirs[-2]
F = np.loadtxt(fullpathf, delimiter = ',')
print(fullpathf, F.shape, dirs, frontname)
# test ss.depth_contour function
L = ss.depth_contours(F)
# save the layers
io.savetxt(os.path.join(path, "depth-cont-cvhull.csv"), L, fmt = '{:d}', delimiter = ',')
# We are not using this since it's exrtemely slow and also doesn't give
# layers if all the points are on a fully convex surface.
# print("Generating depth-contours (project_collapse=False) for " + frontname)
# # test ss.depth_contour function without projection and collapse
# L = ss.depth_contours(F, project_collapse = False)
# save the layers
# io.savetxt(os.path.join(path, "depth-cont-cvhull.csv"), L, fmt = '{:d}', delimiter = ',')
%matplotlib inline
sys.path.append('../')
from vis.utils import io
for pf in list(pfs.keys()):
for dim in pfs[pf]:
fullpathf = "../data/{0:s}/{1:s}/dataf.csv".format(pf, dim)
if os.path.exists(fullpathf):
path, filenamef = os.path.split(fullpathf)
dirs = path.split('/')
frontname = dirs[-2]
F = np.loadtxt(fullpathf, delimiter = ',')
print(fullpathf, F.shape, dirs, frontname)
layerpathf = os.path.join(path, "depth-cont-cvhull.csv")
if os.path.exists(layerpathf):
L = io.loadtxt(layerpathf, dtype = int, delimiter = ',')
if F.shape[1] == 2:
fig = plt.figure()
ax = fig.gca()
for l in L:
ax.scatter(F[l,0], F[l,1], s = 1)
plt.show()
else:
fig = plt.figure()
ax = Axes3D(fig)
for l in L:
ax.scatter(F[l,0], F[l,1], F[l,2], s = 1)
plt.show()